'use strict';

module.exports = app => {
  const { router, controller, middleware } = app;

  // 登录
  router.post('/api/supplier/login', controller.business.supplier.login);
  router.post('/api/purchase/login', controller.business.purchaser.login);

  // ----------------------食堂采购管理----------------------------//
  // 菜品官方参考价格
  router.get('/api/dish/list', controller.business.dish.list);
  router.get('/api/dish/group-list', controller.business.dish.groupList);
  router.post('/api/dish/batch-create', controller.business.dish.batchCreate);
  router.resources('dish', '/api/dish', controller.business.dish);

  // 菜品评价选项
  router.get('/api/dish-rating/list', controller.business.dishRating.list);
  router.resources('dish-rating', '/api/dish-rating', controller.business.dishRating);



  // 供应商
  router.get('/api/supplier/list', controller.business.supplier.list);
  router.resources('supplier', '/api/supplier', controller.business.supplier);

  // 月度比价
  router.get('/api/monthly-bidding/list', controller.business.monthlyBidding.list);
  // 提交入围
  router.post('/api/monthly-bidding/submit-supplier', controller.business.monthlyBidding.submitSupplier);
  router.resources('monthly-bidding', '/api/monthly-bidding', controller.business.monthlyBidding);

  // 供应商报价
  router.get('/api/supplier-quote/list', controller.business.supplierQuote.list);
  router.post('/api/supplier-quote/batch-create', controller.business.supplierQuote.batchCreate);
  router.resources('supplier-quote', '/api/supplier-quote', controller.business.supplierQuote);

  // 参与竞标的供应商
  router.get('/api/bidding-supplier/list', controller.business.biddingSupplier.list);
  router.resources('bidding-supplier', '/api/bidding-supplier', controller.business.biddingSupplier);

  // 每日菜单
  router.get('/api/daily-menu/list', controller.business.dailyMenu.list);
  // 供应商菜单列表
  router.get('/api/daily-menu/supplier-menus', controller.business.dailyMenu.getSupplierMenus);
  // 采购员菜单列表
  router.get('/api/daily-menu/purchaser-menus', controller.business.dailyMenu.getPurchaserMenus);
  // 采购统计数据
  router.get('/api/daily-menu/purchase-statistics', controller.business.dailyMenu.getPurchaseStatistics);
  router.resources('daily-menu', '/api/daily-menu', controller.business.dailyMenu);

  // 菜单详情
  router.get('/api/daily-menu-item/list', controller.business.dailyMenuItem.list);
  router.post('/api/daily-menu-item/batch-create', controller.business.dailyMenuItem.batchCreate);
  router.post('/api/daily-menu-item/batch-update', controller.business.dailyMenuItem.batchUpdate);
  // 收货
  router.post('/api/daily-menu-item/batch-confirm-receipt', controller.business.dailyMenuItem.batchConfirmReceipt);
  // batchConfirmBuy
  router.post('/api/daily-menu-item/batch-confirm-buy', controller.business.dailyMenuItem.batchConfirmBuy);
  router.get('/api/daily-menu-item/menu-items', controller.business.dailyMenuItem.getMenuItems);
  router.resources('daily-menu-item', '/api/daily-menu-item', controller.business.dailyMenuItem);
  // 采购员
  router.get('/api/purchaser/list', controller.business.purchaser.list);
  router.resources('purchaser', '/api/purchaser', controller.business.purchaser);


  // ----------------------租户----------------------------//
  // 租户登录/system/auth/login
  router.post('/api/system/auth/login', controller.system.systemUser.login)
  // 获取租户信息和权限
  router.get('/api/system/auth/get-permission-info', middleware.auth(), controller.system.systemUser.getUserInfo)
  router.resources('/api/system/user', middleware.auth(), controller.system.systemUser);
  // 租户菜单
  router.get('/api/system/menu/tree', middleware.auth(), controller.system.systemMenu.tree);
  router.resources('/api/system/menu', middleware.auth(), controller.system.systemMenu);
  // 角色
  router.get('/api/system/role/list', middleware.auth(), controller.system.systemRole.list);
  router.resources('/api/system/role', middleware.auth(), controller.system.systemRole);
  // 权限
  router.get('/api/system/permission/list-user-roles', middleware.auth(), controller.system.systemPermission.getUserRoles);
  router.post('/api/system/permission/assign-user-role', middleware.auth(), controller.system.systemPermission.updateUserRoles);
  router.get('/api/system/permission/list-role-menus', middleware.auth(), controller.system.systemPermission.listRoleMenus);
  router.post('/api/system/permission/assign-role-menu', middleware.auth(), controller.system.systemPermission.updateRoleMenus);
};
